import {CFormItemProps} from "@/components/CProForm/CFormItem/type";
import {
  ProFormCheckbox,
  ProFormDatePicker,
  ProFormSelect,
  ProFormSwitch,
  ProFormText,
  ProFormTextArea
} from "@ant-design/pro-form";
import FormItem from "antd/es/form/FormItem";
import Upload from "@/components/Upload";
import React from "react";
import ReactQuill from "react-quill";
import 'react-quill/dist/quill.snow.css';
import MapComponent from "@/pages/company/StatefulHOC/MapContainer";
import UploadImage from "@/components/UploadImage";

export default (props: CFormItemProps<any>) => {
  const {Component} = props;
  if (Component) {
    return (
      <FormItem {...props}>
        <Component {...props} {...props.componentProps}/>
      </FormItem>
    )
  }
  switch (props.type) {

    case "select":
      return (<ProFormSelect {...props} {...props.componentProps}/>)
    case "text":
      return (<ProFormTextArea {...props} {...props.componentProps}/>)
    case "dateTime":
      return (<ProFormDatePicker {...props} {...props.componentProps}/>)
    case "check":
      return (<ProFormCheckbox {...props} {...props.componentProps}/>)
    case "switch":
      return (<ProFormSwitch  {...props} {...props.componentProps}/>)
    case "upload":
      return (
        <FormItem {...props}>
          <Upload {...props} {...props.componentProps}/>
        </FormItem>
      )
    case "upload-image":
      return (
        <FormItem {...props}>
          <UploadImage {...props} {...props.componentProps}/>
        </FormItem>
      )
    case "map":
      return <FormItem {...props}><MapComponent {...props} {...props.componentProps}> </MapComponent></FormItem>
    case "quill":
      return (
        <FormItem {...props}>
          <ReactQuill {...props.componentProps} />
        </FormItem>
      )
  }

  return (
    <ProFormText  {...props} {...props.componentProps}/>
  )
}
